package homework06;

import org.junit.Test;


import java.lang.reflect.Method;

public class Demo01 {
    @Test
    public void test1(){
        System.out.println("=====test1====");
    }

    @Test
    public void test2(){
        System.out.println("=====test2====");
    }

    public void test3(){
        System.out.println("=====test3====");
    }
    public void test4(){
        System.out.println("=====test4====");
    }

    public static void main(String[] args) throws Exception{
        //1.先获取Class对象
        Class d01 = Demo01.class;
        //实例化对象，方便方法和成员变量调用
        Demo01 dome = (Demo01) d01.getConstructor().newInstance();
        //2.解析Demo1类中所有的方法对象
        Method[] methods = d01.getDeclaredMethods();
        for (Method method : methods) {
            //3.判断方法上是否有MyTest注解，有就执行该方法
            if (method.isAnnotationPresent(Test.class)){
                method.invoke(dome);
            }
        }
    }
}
